package com.itheima.exception;

public enum ExceptionEnum {
    USER_LOGIN_ERROR("001", "登录失败"),
    USER_REGISTER_ERROR("002", "注册失败");
    private String code; //异常状态码
    private String msg; //异常错误信息
    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    ExceptionEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ExceptionEnum statOf(String code) {
        for (ExceptionEnum state : values()) {
            if (state.getCode().equals(code)) {
                return state;
            }
        }
        return null;
    }

}
